package com.douyin.mapper;

import com.douyin.entity.Video;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

// DAO层,是一些访问 数据库的接口方法
public interface VideoMapper {
    // 增,删 ,改查

    // 查所有
    @Select("select video_id videoId,video_title videoTitle from video")
    List<Video> selectAllVideos();

    // 根据id查一个
    @Select("select video_id videoId,video_title videoTitle from video where video_id =#{id}")
    Video selectVideoById(int id);

    // 根据id删一个
    @Delete("delete from video where video_id =#{id}")
    int deleteVideoById(int id);

    // 添加一个
    @Insert("insert into video (video_title) values  (#{videoTitle})")
    int insertOneVideo(Video video);


    // 修改一个
    @Update("update video set  video_title =#{videoTitle} where video_id=#{videoId}")
    int updateOneVideo(Video video);

}
